home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / music / deliay01.lha / dev / src / ZXAYST11.S < prev    next >
Text File  |  1995-07-06  |  7KB  |  386 lines

  1. ;---------------T
  2.  
  3. DEBUG    equ    0
  4.  
  5.     incdir    includes:
  6.     include    misc/AYPlayer.i
  7.     include    misc/mine.i
  8.     incdir    ''
  9.  
  10.     ifne    DEBUG
  11.  
  12.     lea    song(pc),a0
  13.     bsr.w    initsound
  14.     bsr.w    interrupt
  15.     rts
  16.  
  17. song    dc.b    0,1,2,3
  18.     dc.w    0
  19.     dc.b    0;,0
  20.     incbin    dh2:deliay/tmp/soundtrackersongs.003
  21.     endc
  22.  
  23. * ST11 (SoundTracker 1.1) AY Player, (C) 1995 Patrik Rak - Raxoft
  24.  
  25. * 1 Initial version
  26.  
  27.     STRUCTURE    STRC_Song,0
  28.     UBYTE    ams_assignA    ;0-3 specifies, what amiga channel will be
  29.     UBYTE    ams_assignB    ;assigned to each ay channel (A-C, noise)
  30.     UBYTE    ams_assignC
  31.     UBYTE    ams_assignN
  32.     WORD    ams_fadeoffset    ;precise fade specification
  33.     UWORD    ams_fadelen    ;how long to fade (not supported by DT so far)
  34.                 ;set to zero for neverending song
  35.     ;and so on...
  36.  
  37. ; The Player itself.
  38.  
  39. dd
  40.     AYPLAYERHEADER    ST11
  41.     dc.b    12+1        ;custom ayfreq transpose
  42.     ifeq    DEBUG
  43. AYbase    ds.l    1        ;where ay registers should be "outed"
  44.     else
  45. AYbase    dc.l    ay        ;where ay registers should be "outed"
  46.     endc
  47.     ifeq    DEBUG
  48. AYass    ds.l    1        ;where ay channel assignment should be copied
  49.     else
  50. AYass    dc.l    ay
  51.     endc
  52. AYfreq    ds.l    1        ;from where we take AY frequencies
  53.     dc.w    0        ;initplayer
  54.     dc.w    0        ;endplayer
  55.     dc.w    initsound-*
  56.     dc.w    0        ;endsound
  57.     dc.w    interrupt-*
  58.     dc.w    nextpatt-*
  59.     dc.w    prevpatt-*
  60.     dc.b    'SoundTracker (Polish) 1.0',0
  61.     dc.b    '(C) 19?? ?',0
  62.     dc.b    '(C) 1995 Patrik Rak - Raxoft',0
  63.     even
  64.  
  65. initsound    moveq    #0,d1            ;clear variables
  66.     lea    vars,a1
  67.     moveq    #(data-vars)/2-1,d0
  68. .fill    move.w    d1,(a1)+
  69.     dbra    d0,.fill
  70.  
  71.     move.l    AYass(pc),a2        ;feed PlayAY
  72.     move.l    (a0)+,(a2)        ;with channel assignement
  73.  
  74.     move.w    (a0)+,d2        ;gate fadeoffset
  75.  
  76.     move.w    (a0)+,songfade-data(a1)    ;store fadelen
  77.  
  78.     move.l    a0,(a1)+    ;data
  79.  
  80.     move.w    #$0101,(a1)+    ;curdelay & curpattlen
  81.  
  82.     addq.l    #4,a1
  83.  
  84.     move.b    #1,(a1)+
  85.     move.b    (patcount,a0),d4
  86.     addq.b    #1,d4
  87.     move.b    d4,(a1)+
  88.  
  89.     moveq    #0,d0
  90.     move.b    (delay,a0),d0            ;delay
  91.     moveq    #0,d3
  92.     move.b    (pattlen,a0),d3
  93.     mulu    d0,d3            ;pattlen in VBIs...
  94.  
  95.     move.w    d3,(a1)+    ;vbipattlen
  96.     move.w    d2,(a1)+    ;fadeofset
  97.  
  98. .count    mulu    d3,d4
  99.     add    d2,d4
  100.     move.w    d4,(a1)        ;songlen
  101.     rts
  102.  
  103.     rts
  104.  
  105.  
  106. nextpatt    lea    currpatcount,a6
  107.     moveq    #1,d0
  108.     cmp.b    (a6),d0
  109.     bne.b    dopatterns
  110.     rts
  111.  
  112. prevpatt    lea    currpatcount,a6
  113.     move.w    (a6),d0
  114.     cmp.b    (a6),d0
  115.     beq.b    return
  116.     addq.b    #2,(a6)
  117.     subq.l    #4,position-currpatcount(a6)
  118. dopatterns    move.w    #$101,curdelay-currpatcount(a6)
  119.     tst.l    songlen-currpatcount(a6)
  120.     beq.b    return
  121.     move.b    (a6),d0
  122.     subq.b    #1,d0
  123.     addq.l    #2,a6
  124.     mulu    (a6)+,d0
  125.     add    (a6)+,d0
  126.     move    d0,(a6)
  127. return    rts
  128.  
  129. interrupt    lea    ay,a6    ;base
  130.     lea    data-ay(a6),a0
  131.     move.l    (a0)+,a5    ;data
  132.     moveq    #0,d6        ;use d6 as obsl1 in original
  133.     subq.b    #1,(a0)
  134.     bne.b    .samenote
  135.     moveq    #-1,d6        ;signal new tones
  136.     move.b    delay-xy(a5),(a0)+
  137.     subq.b    #1,(a0)
  138.     bne.b    .samenote
  139.     move.b    pattlen-xy(a5),(a0)+
  140.     move.l    (a0)+,a1
  141.     subq.b    #1,(a0)+
  142.     bne.b    .notend
  143.     move.b    (a0),-(a0)
  144.     lea    patpointers-xy(a5),a1
  145. .notend    moveq    #0,d0
  146.     move.b    (a1)+,d0
  147.     mulu    #3*192,d0
  148.     lea    (patterns-3*192-xy,a5),a0
  149.     add.l    d0,a0
  150.     move.l    a0,ch1-ay(a6)
  151.     addq.l    #3,a0
  152.     move.l    a0,ch2-ay(a6)
  153.     addq.l    #3,a0
  154.     move.l    a0,ch3-ay(a6)
  155.     move.b    (a1)+,transpose+1-ay(a6)
  156.     move.l    a1,position-ay(a6)
  157. .samenote    lea    ch1-ay(a6),a2
  158.     move.l    a6,a3            ;lea    freqa-ay(a6),a3
  159.     lea    vola-ay(a6),a4
  160.     moveq    #0,d5
  161.     st    strobe-ay(a6)    ;all off
  162. .loop    bsr.b    obsluha
  163.     lea    chlen(a2),a2
  164.     addq.l    #2,a3
  165.     addq.l    #1,a4
  166.     addq.b    #1,d5
  167.     cmp.b    #3,d5
  168.     bne.b    .loop
  169.     move.l    AYbase(pc),a1
  170.     moveq    #11-1,d0
  171. .outy    move.b    (a6)+,(a1)+
  172.     dbra    d0,.outy
  173.     move.b    (a6)+,d0
  174.     beq.b    .done
  175.     move.b    (a6)+,(a1)+
  176.     move.b    (a6),(a1)+
  177.     move.b    d0,(a1)
  178. .done    lea    songlen-volc-1(a4),a0
  179.     moveq    #0,d0
  180.     tst.w    (a0)
  181.     beq.b    .exit
  182.     subq.w    #1,(a0)+
  183.     bne.b    .exit
  184.     move.w    (a0),d0
  185. .exit    rts
  186.  
  187. ;a2 channel, a3 freq, a4 volume, d5 how much rotate strobe
  188. ;a5 data, a6 ay
  189.  
  190. obsluha    tst    d6        ;new tones?
  191.     beq.b    .same
  192.     bsr.w    newtone
  193.     add.l    #3*3,(a2)        ;step to next tone
  194.     bra.b    .cont
  195. .same    bsr.w    sametone
  196. .cont    moveq    #0,d2
  197.     move.b    smp(a2),d2    ;sample number
  198.     beq.w    .envel0
  199.  
  200.     moveq    #0,d3
  201.     move.b    (pos,a2),d3
  202.     subq    #1,d2
  203.     mulu    #130,d2
  204.     move.l    a5,a0        ;lea    (samples,a5),a0
  205.     add    d2,a0
  206.     move.l    a0,d2
  207.     lea    (64,a0),a0
  208.     add    d3,a0
  209.     add    d3,a0
  210.  
  211. .cont2    move.w    (a0),d4
  212.     ror.w    #8,d4
  213.     bclr    #4+8,d4
  214.     bne.b    .noneg
  215.     neg    d4
  216. .noneg    add.w    d4,d4
  217.     add.w    d4,d4
  218.     add.w    d4,d4
  219.  
  220.  
  221.     moveq    #0,d0
  222.     move.b    orn(a2),d0
  223.     lsl    #5,d0
  224.     add    d3,d0
  225.     lea    (ornaments,a5),a0
  226.     add    d0,a0
  227.  
  228.     move.w    transpose-ay(a6),d0
  229.     add.b    (a0),d0
  230.     add.b    tone(a2),d0
  231.     add.w    d0,d0
  232.     move.l    AYfreq(pc),a0
  233.     add.w    d0,a0
  234.     add.w    (a0),d4
  235.     move.w    d4,(a3)        ;freq
  236.  
  237.     move.l    d2,a0
  238.     add    d3,a0
  239.     move.b    (a0),d4
  240.     beq.b    .envel0
  241.     lea    (32,a0),a0
  242.     move.b    (a0),d3
  243.     move.b    d3,d2
  244.     moveq    #-2,d0        ;strobe for tone on
  245.     add.b    d2,d2        ;noise off?
  246.     bcs.b    .nonoise
  247.     moveq    #-10,d0        ;strobe for tone and noise on
  248.     and.b    #31,d3
  249.     move.b    d3,noise-ay(a6)    ;noise
  250. .nonoise    add.b    d2,d2
  251.     bcc.b    .toneon
  252.     addq.b    #1,d0        ;turn the tone off
  253. .toneon    rol.b    d5,d0
  254.     and.b    d0,strobe-ay(a6)
  255.     and.b    #16,(a4)    ;keep just previous env on flag!!!
  256.     or.b    d4,(a4)        ;vol
  257. .envel0    rts
  258.  
  259. octtab    dc.b    9,11,0,2,4,5,7
  260.     even
  261.  
  262. newtone    move.l    (a2),a0
  263.     moveq    #0,d0
  264.     move.b    (a0)+,d0
  265.     move    #$f0,d1
  266.     and    d0,d1
  267.     beq.b    sametone
  268.     cmp    #$f0,d1
  269.     beq.b    silentqm
  270.     lsr    #4,d1
  271.     move.b    (octtab-1,pc,d1),d1
  272.     btst    #3,d0
  273.     beq.b    .nois
  274.     addq    #1,d1
  275. .nois    and    #7,d0
  276.     mulu    #12,d0
  277.     add    d1,d0
  278.     move.b    d0,(tone,a2)
  279.     move.b    (a0)+,d0
  280.     move.b    (a0)+,d2
  281.     
  282.     moveq    #15,d1
  283.     and.b    d0,d1
  284.     lea    smpmem(a2),a0
  285.     lsr.b    #4,d0
  286.     bne.b    .newsmpl
  287.     move.b    (a0),d0
  288. .newsmpl    move.b    d0,(a0)+
  289.     move.b    d0,(a0)+
  290.     clr.b    (a0)+
  291.     move.b    #32,(a0)+
  292.     mulu    #130,d0        ;samply jsou cislovany od 1
  293.     move.w    (-2,a5,d0),(a0)    ;takze tohle skace na zac. dalsiho
  294.  
  295.     moveq    #%01111101,d0
  296.     btst    d1,d0
  297.     bne.b    .exit
  298.     clr.b    orn(a2)
  299.     clr.b    (a4)
  300.     cmp.b    #1,d1
  301.     beq.b    .exit
  302.     cmp.b    #15,d1
  303.     bne.b    .env
  304.     and    d1,d2
  305.     move.b    d2,orn(a2)
  306.     rts
  307.  
  308. .env    move.b    #16,(a4)
  309.     move.b    d1,envtype-ay(a6)
  310.     move.b    d2,envfreq-ay(a6)    ;fill only lower byte
  311. .exit    rts
  312.  
  313. silentqm    clr.b    smpmem(a2)
  314. silent    clr.b    smp(a2)
  315.     clr.b    (a4)
  316.     ;rts
  317.  
  318. sametone    addq.b    #1,pos(a2)
  319.     and.b    #31,pos(a2)
  320.     subq.b    #1,len(a2)
  321.     bne.b    .exit
  322.     move.b    rpos(a2),d0
  323.     beq.b    silent
  324.     subq.b    #1,d0
  325.     move.b    d0,pos(a2)
  326.     move.b    rlen(a2),len(a2)
  327.     addq.b    #1,len(a2)
  328. .exit    rts
  329.  
  330.     section    variables,bss
  331. vars
  332. ay
  333. freqa    ds.w    1
  334. freqb    ds.w    1
  335. freqc    ds.w    1
  336. noise    ds.b    1
  337. strobe    ds.b    1
  338. vola    ds.b    1
  339. volb    ds.b    1
  340. volc    ds.b    1
  341. envtype    ds.b    1        ;note that these two
  342. envfreq    ds.w    1        ;lines are swapped!!!
  343.  
  344.     rsreset
  345. strm    rs.l    1        ;Position in pattern stream
  346. tone    rs.b    1        ;Current tone
  347. orn    rs.b    1        ;Ornament number (tone slides)
  348. smpmem    rs.b    1        ;sample nr (same as smp, but this remains intact)
  349. smp    rs.b    1        ;Current sample nr (freq slides, env & noise)
  350. pos    rs.b    1        ;Position in sample/ornament
  351. len    rs.b    1        ;Sample/orn length remaining to loop test
  352. rpos    rs.b    1        ;If, then where start repeating sample/orn
  353. rlen    rs.b    1        ;What len use when looping
  354. chlen    rs.b    0
  355.  
  356. ch1    ds.b    chlen
  357. ch2    ds.b    chlen
  358. ch3    ds.b    chlen
  359.  
  360. data    ds.l    1        ;song data
  361.  
  362. curdelay    ds.b    1
  363. curpattlen    ds.b    1
  364. position    ds.l    1
  365. currpatcount    ds.b    1
  366. patcountpl1    ds.b    1
  367. vbipattlen    ds.w    1
  368. fadeoffset    ds.w    1
  369. songlen    ds.w    1
  370. songfade    ds.w    1
  371. transpose    ds.w    1
  372. varsend
  373. varslen    equ    *-vars
  374.  
  375.     rsreset
  376. xy    rs.b    0
  377. samples    rs.b    15*(32*2+32+32+1+1)
  378. patpointers    rs.b    256*(1+1)
  379. patcount    rs.b    1
  380. ornaments    rs.b    16*32
  381. unknown    rs.b    32    ;(ornaments off?)
  382. delay    rs.b    1
  383. pattlen    rs.b    1
  384. patterns    rs.b    3*(64*(1+1+1));*x
  385.  
  386.